home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-19 | 1.0 KB | 65 lines | [TEXT/MPCC] |
- // OutPoint.cpp
-
-
- #include "OutPoint.h"
-
- #define TIMEOUT 2000
-
-
- OutPoint::OutPoint(
- const char *protocol,
- const char *address,
- short port)
- {
- OSErr err = Open(protocol);
- DNSAddress inAddress;
- InetAddress outAddress;
- TBind inBind = { { 0, sizeof(short)+strlen(address)-1, (UInt8*) &inAddress }, 0};
- TBind outBind = { { sizeof(InetAddress), 0, (UInt8*) &fHisAddress }, 0};
-
- if (err)
- throw err;
-
- err = Bind(port);
- if (err)
- throw err;
-
- inAddress.fAddressType = kOTGenericName;
- strcpy(inAddress.fName, address);
-
- err = OTResolveAddress(fEndpoint, &inBind, &outBind, TIMEOUT);
- if (err)
- throw err;
- fHisAddressSize = outBind.addr.len;
- }
-
-
- OutPoint::~OutPoint()
- {
- }
-
-
- OSErr
- OutPoint::SendData(
- const void *data,
- long size)
- {
-
- OSStatus err;
-
- while (1) {
- TUnitData uData = {
- { 0, fHisAddressSize, (UInt8*) &fHisAddress },
- { 0, 0, NULL },
- { 0, (size_t) size, (UInt8*) data },
- };
-
- err = OTSndUData(fEndpoint, &uData);
- if (err != kOTLookErr)
- break;
- OTRcvUDErr(fEndpoint, nil);
- }
-
- return (OSErr) err;
- }
-